#include <Python.h>

FILE * entree ;
PyObject * modname1, * modname2, * modname3, * modname4 ;
PyObject * module1, * module2, * module3, * module4 ;

int main (int argc, char * argv[])
    {
    entree = fopen("main.py","r");
    
    Py_Initialize()                        ;
    PyRun_SimpleString("import sys; sys.path.insert(0,'.')")            ;
    modname1  =  PyString_FromString("SQ_basic") ;
    module1   =  PyImport_Import(modname1);

    if (module1 == NULL) 
       {
       if (PyErr_Occurred())
	   PyErr_Print();
        fprintf(stderr, "Failed to load \"%s\"\n", module1);
        return 1;
       }

    modname2  =  PyString_FromString("SQ_complex") ;
    module2   =  PyImport_Import(modname2);
    if (module2 == NULL) 
       {
       if (PyErr_Occurred())
	   PyErr_Print();
        fprintf(stderr, "Failed to load \"%s\"\n", module2);
        return 1;
       }

    
    modname3  =  PyString_FromString("SQ_core") ;
    module3   =  PyImport_Import(modname3);
    if (module3 == NULL) 
       {
       if (PyErr_Occurred())
	   PyErr_Print();
        fprintf(stderr, "Failed to load \"%s\"\n", module3);
        return 1;
       }

    modname4  =  PyString_FromString("SQ_io") ;
    module4   =  PyImport_Import(modname4);

    if (module4 == NULL) 
       {
       if (PyErr_Occurred())
	   PyErr_Print();
        fprintf(stderr, "Failed to load \"%s\"\n", module4);
        return 1;
       }

    
   
    PyRun_SimpleString("a = 2")            ;

    PyRun_SimpleFile(entree, "main.py ") ;





    //Py_Main(argc, argv) ;
    Py_DECREF(module1);
    //Py_DECREF(modname1);
    Py_DECREF(module2);
    //Py_DECREF(modname2);
    Py_DECREF(module3);
    //Py_DECREF(modname3);
    Py_DECREF(module4);
    //Py_DECREF(modname4);

    Py_Finalize()                          ;
    return 0                               ;

    
    }


